from app import db

class Exponent(db.Model):
    __tablename__ = 'exponent'
    
     # 设置联合主键
    pid = db.Column(db.String(50), primary_key=True)
    cid = db.Column(db.String(50), primary_key=True)
    mteam = db.Column(db.String(20), nullable=False)
    dopen = db.Column(db.String(20), nullable=False)
    vteam = db.Column(db.String(20), nullable=False)
    mteam2 = db.Column(db.String(20), nullable=False)
    dopen2 = db.Column(db.String(20), nullable=False)
    vteam2 = db.Column(db.String(20), nullable=False)
    created_at = db.Column(db.DateTime, default=db.func.current_timestamp())  

    def to_dict(self):
        """转换为字典，方便接口返回"""
        return {
            'pid': self.pid,
            'cid': self.cid,
            'mteam': self.mteam,
            'dopen': self.dopen,
            'vteam': self.vteam,
            'mteam2': self.mteam2,
            'dopen2': self.dopen2,
            'vteam2': self.vteam2,
            'created_at': self.created_at.isoformat()
        }
